package com.example.carRental.utils;

import java.util.Random;

/**
 * @author 92307
 * @version 1.0
 * @time 2022/3/24
 * @Describe 用于获得16位长的随机字符串
 */
public class RandomStr {
    private static final String str="zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
    public static String getRandomStr(){
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        //长度为几就循环几次
        for(int i=0; i<32; ++i){
            //产生0-61的数字
            int number=random.nextInt(62);
            //将产生的数字通过length次承载到sb中
            sb.append(str.charAt(number));
        }
        //将承载的字符转换成字符串
        return sb.toString();
    }
}
